package org.jash.imdemo;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.viewpager2.widget.ViewPager2;

import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

import org.jash.imdemo.fragment.WechatAdapter;

public class WechatActivity extends AppCompatActivity {
    private ViewPager2 pager;
    private TabLayout tab;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wechat);
        pager =findViewById(R.id.pager);
        pager.setAdapter(new WechatAdapter(this));
        tab  = findViewById(R.id.tab);
        new TabLayoutMediator(tab, pager, (tab1, position) -> {
            switch (position) {
                case 0:
                    tab1.setText("会话");
                    tab1.setIcon(R.drawable.baseline_chat_24);
                    break;
               case 1:
                    tab1.setText("联系人");
                    tab1.setIcon(R.drawable.baseline_contacts_24);
                    break;
               case 2:
                    tab1.setText("我的");
                    tab1.setIcon(R.drawable.baseline_person_24);
                    break;
            }
        }).attach();
    }
}